package collection01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author Huangjin
 * @version 1.0
 * describe:z增强for循环:新循环
 * @date 2023/3/2 18:59
 */
public class NewForDemo {
    public static void main(String[] args) {
        String[] array = {"One","Two","Three","Four","Five"};
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
        for (String s : array) {
            System.out.println(s);
        }
        Collection c = new ArrayList();
        c.add("One");
        c.add("Two");
        c.add("Three");
        c.add("Four");
        c.add("Five");
        Iterator it = c.iterator();
        while (it.hasNext()){
            String str = (String) it.next();
            System.out.println(str);
        }
        for (Object obj:c){
            String str = (String) obj;
            System.out.println(str);
        }
    }
}
